﻿namespace EasyToolkit.Excel.UI.SortAndFilter
{
    using System.Windows.Interop;
    using EasyToolkit.BindingTemplates.Views;
    using EasyToolkit.Excel.UI.BindingTemplate.SortAndFilter.ViewModels;
    using EasyToolkit.Excel.UI.SortAndFilter;
    
    static class SortAndFilterManagement
    {
        public static void DisplaySortAndFilterWindow(IRootTemplateView rootTemplateView)
        {
            DisplaySortAndFilterWindow(null, rootTemplateView);
        }

        public static void DisplaySortAndFilterWindow(System.Windows.Forms.IWin32Window owner, IRootTemplateView rootTemplateView)
        {
            SortAndFilterViewModel viewModel = new SortAndFilterViewModel(rootTemplateView);
            SortAndFilerWindow window = new SortAndFilerWindow(rootTemplateView);
            if (owner != null)
            {
                WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window);
                windowInteropHelper.Owner = owner.Handle;
                window.ShowDialog();
            }
            else 
                window.ShowDialog();
        }

    }
}
